class Word:
    """单词模型类，存储单词信息和学习状态"""
    
    def __init__(self, word: str, meaning: str, phonetic: str = "", 
                 example: str = "", category: str = "", mastery_level: int = 0):
        self.word = word
        self.phonetic = phonetic
        self.meaning = meaning
        self.example = example
        self.category = category
        self.mastery_level = mastery_level  # 0: 未学习, 1: 学习中, 2: 已掌握
        
    def __str__(self) -> str:
        return f"{self.word} - {self.meaning[:30]}..."
        
    def to_dict(self) -> dict:
        """转换为字典，用于JSON序列化"""
        return {
            'word': self.word,
            'phonetic': self.phonetic,
            'meaning': self.meaning,
            'example': self.example,
            'category': self.category,
            'mastery_level': self.mastery_level
        }